<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>后台管理</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache"/>
    <meta http-equiv="expires" content="0"/>
    <!-- styles -->
    <link rel="stylesheet" type="text/css" href="../../assets/common/jquery-easyui/themes/gray/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../assets/common/jquery-easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../assets/common/jquery-easyui-custom/easyui.custom.css">
    <!-- scripts -->
    <script type="text/javascript" src="../../assets/common/jquery-easyui/jquery.min.js"></script>
    <script type="text/javascript" src="../../assets/common/jquery-easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../assets/common/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../assets/common/jquery-easyui-custom/easyui.custom.js"></script>
    <script type="text/javascript" src="../../assets/common/framework.js"></script>
    <!-- page scripts -->
    <script type="text/javascript">
        var menuOfTab;
        $(function () {
            $('#tabs').tabs({
                onContextMenu: function (e, title, index) {
                    e.preventDefault();
                    if (index != 0) {
                        menuOfTab = index;
                        $('#menu').menu('show', {
                            left: e.pageX,
                            top: e.pageY
                        });
                    }
                },
                onSelect: function (title, index) {
                    // 该方式可以在选中后自动刷新tab，但会使得效率下降
                    /* var content = $(this).tabs('getTab', index).panel('options').content;
                     $(this).tabs('getTab', index).panel({
                     content : content
                     }); */
                }
            });
            // 获取用户信息
            $.ajax({
                type: 'post',
                url: '/getLoginInfo',
                dataType: 'json',
                async: true,
                success: function (data) {
                    if (data.status == 0) {
                        //合同管理
                        var contractManager = '<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">' +
                            '<li><a onclick="tab_add(\'合同管理\',\'/views/contract/contract.html\')">合同管理</a></li>' +
                            '</ul>';
                        //用户管理
                        var userManager = '<ul class=\"easyui-tree\" data-options=\"onBeforeSelect:function(node){return false;}\">' +
                            '<li><a onclick=\"tab_add(\'企业信息管理\',\'/views/enterpriseDetail/enterpriseDetail.html\')\">企业信息管理</a></li>' +
                            '<li><a onclick=\"tab_add(\'个人用户信息管理\',\'/views/individualUser/individualUser.html\')\">个人用户信息管理</a></li>' +
                            '</ul>';


                        //项目管理
                        var projectManager = ' <ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">' +
                            '<li><a onclick="tab_add(\'企业项目管理\',\'/views/enterpriseProject/enterpriseProject.html\')">企业项目管理</a></li>' +
                            '<li>' +
                            '<a onclick="tab_add(\'客服项目管理\',\'/views/projectMuserEmployeeRelation/projectMuserEmployeeRelation.html\')">客服项目管理</a>' +
                            '</li>' +
                            '</ul>';
                        //订单管理
                        var orderManager = '<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">' +
                            '<li><a onclick="tab_add(\'客服订单管理\',\'/views/customerServiceOrder/customerOrder.html\')">客服订单管理</a></li>' +
                            '</ul>';
                        //政策管理
                        var policyManager = '<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">' +
                            '<li><a onclick="tab_add(\'社保基数比例管理\',\'/views/baseRatio/baseRatio.html\')">社保基数比例管理</a></li>' +
                            '<li>' +
                            '<a onclick="tab_add(\'公积金比例管理\',\'/views/housingFundBaseRatio/housingFundBaseRatio.html\')">公积金比例管理</a>' +
                            '</li>' +
                            '<li>' +
                            '<a onclick="tab_add(\'缴纳社保所需资料\',\'/views/paySocialInsuranceMaterial/paySocialInsuranceMaterial.html\')">缴纳社保所需资料</a>' +
                            '</li>' +
                            '<li>' +
                            '<a onclick="tab_add(\'服务模板管理\',\'/views/socialSecurityServiceTemplate/socialSecurityServiceTemplate.html\')">服务模板管理</a>' +
                            '</li>' +
                            '</ul>';

                        //财务管理
                        var financeManager = '<ul class=\"easyui-tree\" data-options="onBeforeSelect:function(node){return false;}\">' +
                            '<li><a onclick=\"tab_add(\'实到款管理\',\'/views/actualReceive/actualReceive.html\')\">实到款管理</a></li>' +
                            '<li><a onclick=\"tab_add(\'应收款管理\',\'/views/accountsReceivable/accountsReceivable.html\')">应收款管理</a></li>' +
                            '<li><a onclick=\"tab_add(\'科目管理\',\'/views/invoiceSubjects/invoiceSubjects.html\')\">科目管理</a></li>' +
                            '<li><a onclick=\"tab_add(\'开票管理\',\'/views/invoiceApplication/invoiceApplication.html\')">开票管理</a></li>' +
                            '</ul>';

                        //供应商管理
                        var supplyManager = '<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">' +
                            '<li><a onclick="tab_add(\'供应商管理\',\'/views/supplierDetail/supplierDetail.html\')\">供应商管理</a></li>' +
                            '<li><a onclick="tab_add(\'供应商合同管理\',\'/views/supplierContract/supplierContract.html\')\">供应商合同管理</a></li>' +
                            '</ul>';

                        //社保专员
                        var supporter = '<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">' +
                            '<li><a onclick="tab_add(\'增减员\',\'/views/employeeHouseFundingSocialInsuranceOrder/employeeHouseFundingSocialInsuranceOrder.html\')\">增减员</a></li>' +
                            '<li><a onclick="tab_add(\'供应商订单\',\'/views/supplierOrder/supplierOrder.html\')\">供应商订单</a></li>' +
                            '</ul>';


                        $('#nav .username').html(data.dataWrapper.user.realName);
                        var role = data.dataWrapper.role;
//                        $("#userManager").css('display', 'none');
                        if (role.roleName == '销售') {
                            $('#layout_west_accordion').accordion('add', {
                                title: '合同管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + contractManager + '</div>',
                            });
                        } else if (role.roleName == '财务') {
                            $('#layout_west_accordion').accordion('add', {
                                title: '财务管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + financeManager + '</div>',
                            });
                        } else if (role.roleName == '社保') {
                            $('#layout_west_accordion').accordion('add', {
                                title: '政策大全',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + policyManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '供应商管理',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + supplyManager + '</div>',
                            });
                        } else if (role.roleName == '客服') {
                            $('#layout_west_accordion').accordion('add', {
                                title: '用户管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + userManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '合同管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + contractManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '项目管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + projectManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '订单管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + orderManager + '</div>',
                            });
                        } else if (role.roleName == '管理员') {
                            $('#layout_west_accordion').accordion('add', {
                                title: '用户管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + userManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '合同管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + contractManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '项目管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + projectManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '订单管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + orderManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '政策大全',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + policyManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '供应商管理',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + supplyManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '财务管理功能',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + financeManager + '</div>',
                            });
                            $('#layout_west_accordion').accordion('add', {
                                title: '社保专员',
                                iconCls: 'icon-table',
                                selected: false,
                                content: '<div style="padding:10px">' + supporter + '</div>',
                            });
                        }

                    }
                }
            });
            // 访问来源判断（流程设计器返回预留）
            var from = window.location.search.substring(6);
        });
        function tab_add(title, url) {
            if ($('#tabs').tabs('exists', title)) {
                $('#tabs').tabs('select', title);
            } else {
                var content = '<iframe scrolling="auto" frameborder="0" src="'
                    + url + '" style="width:100%; height:100%;"></iframe>';
                $('#tabs').tabs('add', {
                    title: title,
                    content: content,
                    closable: true
                });
            }
        }
        function tab_refresh() {
            var content = $('#tabs').tabs('getTab', menuOfTab).panel('options').content;
            $('#tabs').tabs('getTab', menuOfTab).panel({
                content: content
            });
        }
        function tab_close() {
            $('#tabs').tabs('close', menuOfTab);
        }
        function dlg_change() {
            $('#fm-change').form('clear');
            $('#dlg-change').dialog('open');
        }
        function func_change() {
            // 这里是利用html中的form进行提交，所以需要加上项目路径AppCore.baseUrl
            var newPass = $('#fm-change [name="newPass"]').val();
            var rePass = $('#fm-change [name="rePass"]').val();
            if (newPass == rePass) {
                $('#fm-change').form('submit', {
                    url: AppCore.baseUrl + 'admin/common/change',
                    onSubmit: function (param) {
                        return $(this).form('validate');
                    },
                    success: function (data) {
                        var data = eval('(' + data + ')');
                        if (data.success) {
                            // 成功后需要注销账号
                            $('#dlg-change').dialog('close');
                            $.messager.alert({
                                title: '提示',
                                msg: '修改成功，需要重新登录！',
                                icon: 'info',
                                fn: function () {
                                    func_logout();
                                }
                            });
                        } else {
                            $.messager.show({
                                title: '错误',
                                msg: data.msg,
                                showType: 'fade',
                                style: {
                                    right: '',
                                    bottom: ''
                                }
                            });
                        }
                    }
                });
            } else {
                $.messager.show({
                    title: '错误',
                    msg: '两次输入的密码不一致！',
                    showType: 'fade',
                    style: {
                        right: '',
                        bottom: ''
                    }
                });
            }
        }
        function func_logout() {
            $.ajax({
                type: 'post',
                url: '/logout',
                dataType: 'json',
                async: true,
                success: function (data) {
                    if (data.status == 0) {
                        window.location.href = '/views/main/login.html';
                    } else {
                        $.messager.show({
                            title: '错误',
                            msg: data.msg,
                            showType: 'fade',
                            style: {
                                right: '',
                                bottom: ''
                            }
                        });
                    }
                },
                error: function () {
                    $.messager.show({
                        title: '错误',
                        msg: '服务器正忙，请稍后再试！',
                        showType: 'fade',
                        style: {
                            right: '',
                            bottom: ''
                        }
                    });
                }
            });
        }
    </script>
    <style type="text/css">
        .panel-header {
            height: 18px;
        }

        #nav {
            list-style-type: none;
            display: block;
            height: 21px;
            position: absolute;
            top: 40px;
            right: 5px;
        }

        #nav li {
            float: left;
            margin-left: -1px;
            padding: 3px 5px;
            line-height: 20px;
            position: relative;
        }

        #nav li a {
            line-height: 20px;
        }
    </style>
</head>

<body class="easyui-layout" data-options="fit:true">
<div data-options="region:'north'" style="height:80px;overflow:hidden;">
    <!-- 右上角工具条 -->
    <ul id="nav">
        <li>欢迎使用，<b class="username">admin</b></li>
        <!--<li><a href="javascript:;" onclick="dlg_change()">修改密码</a></li>-->
        <li><a href="javascript:;" onclick="func_logout()">退出</a></li>
    </ul>
</div>
<div data-options="region:'west',title:'&nbsp;菜单栏',split:true,iconCls:'icon-table'" style="width:180px;">
    <div class="easyui-accordion" data-options="fit:true,border:false,selected:0" id="layout_west_accordion">
        <!--<div data-options="title:'&nbsp;用户管理',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--<li><a onclick="tab_add('企业信息管理','/views/enterpriseDetail/enterpriseDetail.html')">企业信息管理</a></li>-->
        <!--&lt;!&ndash;<li><a onclick="tab_add('员工信息管理','/views/employeeUser/employeeUser.html')">员工信息管理</a></li>&ndash;&gt;-->
        <!--<li><a onclick="tab_add('个人用户信息管理','/views/individualUser/individualUser.html')">个人用户信息管理</a></li>-->
        <!--</ul>-->
        <!--</div>-->
        <!--<div data-options="title:'&nbsp;合同管理功能',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--<li><a onclick="tab_add('合同管理','/views/contract/contract.html')">合同管理</a></li>-->
        <!--</ul>-->
        <!--</div>-->
        <!--<div data-options="title:'&nbsp;项目管理功能',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--<li><a onclick="tab_add('企业项目管理','/views/enterpriseProject/enterpriseProject.html')">企业项目管理</a></li>-->
        <!--<li>-->
        <!--<a onclick="tab_add('客服项目管理','/views/projectMuserEmployeeRelation/projectMuserEmployeeRelation.html')">客服项目管理</a>-->
        <!--</li>-->

        <!--</ul>-->
        <!--</div>-->
        <!--<div data-options="title:'&nbsp;订单管理功能',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--&lt;!&ndash;<li><a onclick="tab_add('企业订单管理','/views/enterpriseOrder/enterpriseOrder.html')">企业订单管理</a></li>&ndash;&gt;-->
        <!--<li><a onclick="tab_add('客服订单管理','/views/customerServiceOrder/customerOrder.html')">客服订单管理</a></li>-->

        <!--</ul>-->
        <!--</div>-->
        <!--<div data-options="title:'&nbsp;政策大全',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--<li><a onclick="tab_add('保险基数比例管理','/views/baseRatio/baseRatio.html')">保险基数比例管理</a></li>-->
        <!--<li>-->
        <!--<a onclick="tab_add('各地公积金比例管理','/views/housingFundBaseRatio/housingFundBaseRatio.html')">各地公积金比例管理</a>-->
        <!--</li>-->
        <!--<li>-->
        <!--<a onclick="tab_add('缴纳社保所需资料','/views/paySocialInsuranceMaterial/paySocialInsuranceMaterial.html')">缴纳社保所需资料</a>-->
        <!--</li>-->
        <!--<li>-->
        <!--<a onclick="tab_add('服务模板管理','/views/socialSecurityServiceTemplate/socialSecurityServiceTemplate.html')">服务模板管理</a>-->
        <!--</li>-->
        <!--</ul>-->
        <!--</div>-->
        <!--<div data-options="title:'&nbsp;财务管理功能',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--<li><a onclick="tab_add('实到款管理','/views/actualReceive/actualReceive.html')">实到款管理</a></li>-->
        <!--<li><a onclick="tab_add('科目管理','/views/invoiceSubjects/invoiceSubjects.html')">科目管理</a></li>-->
        <!--<li><a onclick="tab_add('开票管理','/views/invoiceApplication/invoiceApplication.html')">开票管理</a></li>-->
        <!--</ul>-->
        <!--</div>-->
        <!--<div data-options="title:'&nbsp;供应商管理',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--<li><a onclick="tab_add('供应商管理','/views/supplierList/supplierList.html')">供应商管理</a></li>-->
        <!--</ul>-->
        <!--</div>-->
        <!--<div data-options="title:'&nbsp;测试功能',iconCls:'icon-page'" style="padding:8px;">-->
        <!--<ul class="easyui-tree" data-options="onBeforeSelect:function(node){return false;}">-->
        <!--<li>-->
        <!--<a onclick="tab_add('测试功能','/views/employeeHouseFundingSocialInsuranceOrder/employeeHouseFundingSocialInsuranceOrder.html')">员工订单</a>-->
        <!--</li>-->
        <!--</ul>-->
        <!--</div>-->
    </div>
</div>
<div data-options="region:'center',border:false">
    <div data-options="fit:true" class="easyui-tabs" id="tabs">
        <div title="主页"></div>
    </div>
    <div id="menu" class="easyui-menu">
        <div data-options="iconCls:'icon-reload'" onclick="tab_refresh()">刷新</div>
        <div data-options="iconCls:'icon-cancel'" onclick="tab_close()">关闭</div>
    </div>
</div>
<!-- 修改密码 -->
<div id="dlg-change" class="easyui-dialog" style="width:320px;padding:20px 30px;"
     data-options="title:'修改密码',closed:true,modal:true,buttons:'#dlg-btn-change'">
    <form id="fm-change" method="post">
        <input type="hidden" id="id-change"/>
        <input type="hidden" id="orgId-change" name="orgId"/>
        <div style="text-align: center;">
            <table style="border-width:0;" align="center">
                <tr>
                    <td style="text-align: right;">旧密码：</td>
                    <td><input type="password" name="oldPass" class="easyui-textbox" data-options="required:true"/></td>
                </tr>
                <tr>
                    <td style="text-align: right;">新密码：</td>
                    <td><input type="password" name="newPass" class="easyui-textbox"
                               data-options="required:true,validType:'loginPass'"/></td>
                </tr>
                <tr>
                    <td style="text-align: right;">重复新密码：</td>
                    <td><input type="password" name="rePass" class="easyui-textbox"
                               data-options="required:true,validType:'loginPass'"/></td>
                </tr>
            </table>
        </div>
    </form>
    <div id="dlg-btn-change">
        <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="func_change()">确定</a>
        <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'"
           onclick="$('#dlg-change').dialog('close');">取消</a>
    </div>
</div>
</body>
</html>
